package treeHoleSERVICE;

import treeHoleDAO.AccountInformation;
import treeHoleDAO.AccountInformationIMPH;

import java.io.IOException;
import java.util.Map;


/**
 * @program:IntelliJ IDEA
 * @Description:Landing的实现类
 * @author:Mr.CheCheHuiBujianO
 * @data: 2022/6/20 16:00
 */
public class LandingIMPH implements Landing{
    /**
     * @param userAccount
     * @param userPassword
     * @Description: 利用用户输入的账号和密码和我们读取账号文件信息判断进行判断
     * 正确传回true，否则反之
     * @Param: [userAccount, userPassword]
     * @return:[ java.lang.String]
     * @Author: Mr.xin
     * @Date: 2022/6/16 11:21
     */
    @Override
    public boolean landing(int userAccount, String userPassword) {
        AccountInformation a = new AccountInformationIMPH();
        Map<Integer, String> gather = null;
        try {
            gather = a.readAccountInformation();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        for(Map.Entry<Integer, String> entry:gather.entrySet()){
            if (userAccount != entry.getKey()) {
                continue;
            } else if (userPassword.equals(entry.getValue())) {
                return true;
            }
        }
        return false;
    }

}
